package Servlet;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;

import Bean.User;
import ServiceImpl.UserServiceImpl;

/**
 * Servlet implementation class SelectUserServlet
 */
public class SelectUserServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       

    public SelectUserServlet() {

    }

	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request,response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setContentType("text/html charset = UTF-8");
		User user = null;
		UserServiceImpl userservice = new UserServiceImpl();
		String username=request.getParameter("username");
		user=userservice.selectUser(username);
		request.setAttribute("user", user);
		System.out.print(user);
		request.getRequestDispatcher("select_user.jsp").forward(request, response);
	}

}
